package mamikeji.liaowa.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;

import java.util.ArrayList;
import java.util.List;

import mamikeji.liaowa.R;
import mamikeji.liaowa.bean.FriendCircleInfoBean;

/**
 * Created by 廉冲-android开发 on 2017/5/17.
 */
public class Comment_dynamicAdapter extends BaseAdapter {
    List<FriendCircleInfoBean.FriendchatEntity> mList = new ArrayList<>();
    LayoutInflater inflater;
    Context context;

    public Comment_dynamicAdapter() {
    }

    public Comment_dynamicAdapter(List<FriendCircleInfoBean.FriendchatEntity> mList, Context context) {
        this.mList = mList;
        this.context = context;
        inflater = LayoutInflater.from(context);
    }

    public void setList(List<FriendCircleInfoBean.FriendchatEntity> mList) {
        this.mList = mList;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.item_main_dynamic, null);
            viewHolder = new ViewHolder();

//            viewHolder.textView_details_comment_username = (TextView) convertView.findViewById(R.id.textView_article_details_username);
//            viewHolder.textView_details_recomment_recommentusername = (TextView) convertView.findViewById(R.id.textView_details_recomment_recommentusername);
//            viewHolder.textView_dynamic_comment_content_details = (TextView) convertView.findViewById(R.id.textView_article_details_content);
//            viewHolder.imageView_details_comment_userimg = (SimpleDraweeView) convertView.findViewById(R.id.imageView_article_details_userimg);
//            viewHolder.linearLayout_dynamic_recomment_details = (LinearLayout)convertView.findViewById(R.id.linearLayout_dynamic_recomment_details);

            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        FriendCircleInfoBean.FriendchatEntity friendchatEntity = mList.get(position);

//        viewHolder.textView_details_comment_username.setText(friendchatEntity.getName());
//        viewHolder.textView_dynamic_comment_content_details.setText(friendchatEntity.getContent());
//        viewHolder.imageView_details_comment_userimg.setImageURI(Uri.parse(friendchatEntity.getAvatar()));

//        if (friendchatEntity.getReplysid() <= 0){
//            viewHolder.linearLayout_dynamic_recomment_details.setVisibility(View.GONE);
//        }else {
//            viewHolder.linearLayout_dynamic_recomment_details.setVisibility(View.VISIBLE);
//            viewHolder.textView_details_recomment_recommentusername.setText(friendchatEntity.getRusercode());
//        }

        return convertView;
    }

    public class ViewHolder {
        TextView textView_details_comment_username;
        TextView textView_details_recomment_recommentusername;
        TextView textView_dynamic_comment_content_details;
        LinearLayout linearLayout_dynamic_recomment_details;
        SimpleDraweeView imageView_details_comment_userimg;
    }

}
